有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java为什么不推荐“使用getString()获取设备标识符”?

我正试图将我的设备ID设置为Logcat,但Android Studio给了我这个警告

using getstring to get device identifiers is not recommended

String deviceID = Settings.Secure.getString(getApplicationContext().getContentResolver(),
        Settings.Secure.ANDROID_ID);

为什么不推荐


共 (1) 个答案

  1. # 1 楼答案

    完整的警告说:

    Using these device identifiers is not recommended other than for high value fraud prevention and advanced telephony use-cases. For advertising use-cases, use AdvertisingIdClient$Info#getId and for analytics, use InstanceId#getId.

    More info: https://developer.android.com/training/articles/user-data-ids.html

    我认为Android不建议使用这个值,因为它是一个永久的唯一id,可以用来跟踪你的用户,他或她不能更改这个id或阻止你阅读它。警告中给出的其他选项尊重用户的意愿。这就是为什么安卓建议你使用它

    这真的取决于你将如何使用这个id。现在隐私是一件敏感的事情

    请检查以下内容:

    ...you must abide by a user’s ‘Opt out of interest-based advertising’ or 'Opt out of Ads Personalization' setting. If a user has enabled this setting, you may not use the advertising identifier for creating user profiles for advertising purposes or for targeting users with personalized advertising. Allowed activities include contextual advertising, frequency capping, conversion tracking, reporting and security and fraud detection.

    资料来源:https://developer.android.com/training/articles/user-data-ids.html